﻿import logging

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, Session

from util.LogHelper import Log

engine = create_engine("mysql+pymysql://admin:123@60.205.132.214:3306/hems?charset=utf8",
                       echo=True,
                       pool_size=5
                       )

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()


def get_db_session():
    db: Session = SessionLocal()
    try:
        yield db
    finally:
        db.close()

